package com.ailink.design.pattern.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by Administrator on 2018/8/6
 */
public class TimeHandler implements InvocationHandler {

    private Object object;

    public TimeHandler(Object object) {
        super();
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long startTime = System.currentTimeMillis();
        method.invoke(object, args);
        long endTime = System.currentTimeMillis();
        System.out.println("汽车行驶了：" + (endTime - startTime) + "毫秒");
        return null;
    }
}
